/*
* UserController.java
* Created on  2013-9-26 下午10:42
* 版本       修改时间          作者      修改内容
* V1.0.1    2013-9-26       gaoxinyu    初始版本
*
*/
package com.genghis.ptas.note;

import com.genghis.ptas.note.entity.NoteInfo;
import com.genghis.ptas.note.service.NoteService;
import com.genghis.ptas.security.service.UserService;
import com.genghis.ptas.util.LoginUserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author tiangc
 * @version 1.0.1
 */
@Controller
@Transactional
@RequestMapping("/note/")
public class NoteController {
    @Autowired
    private NoteService noteService;

    @Autowired
    private UserService userService;

    @RequestMapping(value = "saveNote", method = {RequestMethod.POST})
    @ResponseBody
    public void saveNote(NoteInfo noteInfo) {
        int userId = userService.findUserByLoginName(LoginUserUtil.findLoginUserName()).getId();
        noteService.addNoteInfo(noteInfo, userId);
    }
    @RequestMapping(value = "editNote", method = {RequestMethod.POST})
    @ResponseBody
    public void editNote(NoteInfo noteInfo) {
        int userId = userService.findUserByLoginName(LoginUserUtil.findLoginUserName()).getId();
        noteService.editNote(noteInfo, userId);
    }
}
